#include <iostream>

using namespace std;

class Solution {
private:
    bool dfs(string& num, int index, int64_t num1, int64_t num2) {
        if (index == num.size()) {
            return true;
        }
        int left_num = num.size() - index;
        if (num[index] == '0') {
            left_num = 1;
        }
        for (int i = 1; i <= left_num; i++) {
            int64_t num3 = strtol(num.substr(index, i).data(), nullptr, 10);
            if (num1 + num2 == num3) {
                if (dfs(num, index + i, num2, num3)) {
                    return true;
                }
            }
        }
        return false;
    }
public:
    bool isAdditiveNumber(string num) {
        int max_len1 = num.size() - 2;
        if (num[0] == '0') {
            max_len1 = 1;
        }
        for (int i = 1; i <= max_len1; i++) {
            int64_t num1 = strtol(num.substr(0, i).data(), nullptr, 10);
            int max_len2 = num.size() - i - 1;
            if (num[i] == '0') {
                max_len2 = 1;
            }
            for (int j = 1; j <= max_len2; j++) {
                int64_t num2 = strtol(num.substr(i, j).data(), nullptr, 10);
                if (dfs(num, i + j, num1, num2)) {
                    return true;
                }
            }
        }
        return false;
    }
};



int main() {
    Solution solution;
    solution.isAdditiveNumber("199111992");
    return 0;
}